<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
  
  $("h2").blur(function(){
    test();
  });
});
</script>
    <script>
        localStorage
        function test() {

            var name=document.getElementById("name").value;
            var a=localStorage.getItem(name);
            if(a!=null){
                alert("提示\n\n用户名已被使用");
                return false;
            }

            var temp=document.getElementById("email");
            var myreg=/^[a-zA-Z0-9]+@([a-zA-Z0-9]+\.)+(com|cn|net|org)$/;
            if(!myreg.test(temp.value)) {
                alert("提示\n\n请输入有效的邮箱");
                myreg.focus();
                return false;
            }

            var tem=document.getElementById("email").value;
            var b=localStorage.getItem(tem);
            if(b!=null){
                alert("提示\n\n邮箱已被使用");
                return false;
            }
            var password=document.getElementById("password");
            var p1=/^(?!([a-zA-Z]+|\d+)$)[a-zA-Z\d]{8,16}$/;
            if (!p1.test(password.value)){
                alert("提示\n\n密码必须包含字母和数字且长度为8-16位");

                return false;
            }
            var pass=document.getElementById("password").value;
            var password2=document.getElementById("password2").value;
            if (pass!=password2){
                alert("提示\n\n请确认两次密码输入一致");
                return false;
            }
            else {
                var data=new Object;
                data.name=document.getElementById("name").value;
                data.password=document.getElementById("password").value;
                data.email=document.getElementById("email").value;
                var t=new Date();
                data.timenow=t.toLocaleString();
                var ti=JSON.stringify(data);
                localStorage.setItem(data.name,ti);
                alert("注册成功");
                window.location.href = 'http://wasd897586363.gitee.io/dengluchenggong';
            }
        }
    </script>
    
<title>注册</title>

<style type="text/css">


</style>
<style type="text/css">
<!--body {

	background-image: url(风流背景.jpg);
	background-repeat: no-repeat;
	text-align: center;
	background-position: center;
}a:link {
	text-decoration: none;
	color: #000000;
}
a:visited {
	text-decoration: none;
	color: #000000;
}
a:hover {
	text-decoration: none;
}
a:active {
	text-decoration: none;
}
-->
</style>
</head>

<body>
<form id="registerform" name="form" onsubmit="save();" method="get" action="登录.html">
    <legend><h1>注册</h1></legend>
<div class="form0">
    <label for="name"> <h2>用户名</h2></label>
<input type="text" name="name" id="name" value="">
    </div>



<label for="email"><h2>邮箱</h2></label>
<input type="email" name="email" id="email">
        <label for="password"> <h2>密码</h2></label>
<input type="password" id="password" value="" maxlength="10">

<h2>确认密码</h2>
<input type="password" id="password2" value="">
        <br><br><br>
<img onclick="test()" src="注册2.jpg" width="151" height="90" alt=""/>
<a href="http://wasd897586363.gitee.io/denglu/">
<h3>登录</h3></a></form>
<br><br><br><br><br><br>
<footer>Welcome to 风流 ...</footer>
</body>
</html>
